package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sebas
 */
@Entity
@Table(name = "artist")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Artist.findByName", query = "SELECT a FROM Artist a WHERE a.artName LIKE :artName OR a.artLastname LIKE :artLastname"),
    @NamedQuery(name = "Artist.findAll", query = "SELECT a FROM Artist a"),
    @NamedQuery(name = "Artist.findByIdArtist", query = "SELECT a FROM Artist a WHERE a.idArtist = :idArtist"),
    @NamedQuery(name = "Artist.findByArtBirthdate", query = "SELECT a FROM Artist a WHERE a.artBirthdate = :artBirthdate")})
public class Artist implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_artist")
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer idArtist;
    @Basic(optional = false)
    @Lob
    @Column(name = "art_name")
    private String artName;
    @Basic(optional = false)
    @Lob
    @Column(name = "art_lastname")
    private String artLastname;
    @Basic(optional = false)
    @Lob
    @Column(name = "art_picture")
    private String artPicture;
    @Basic(optional = false)
    @Column(name = "art_birthdate")
    @Temporal(TemporalType.DATE)
    private Date artBirthdate;
    @Basic(optional = false)
    @Lob
    @Column(name = "art_birthplace")
    private String artBirthplace;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "artistIdArtist")
    private Collection<Song> songCollection;

    public Artist() {
    }

    public Artist(Integer idArtist) {
        this.idArtist = idArtist;
    }

    public Artist(Integer idArtist, String artName, String artLastname, String artPicture, Date artBirthdate, String artBirthplace) {
        this.idArtist = idArtist;
        this.artName = artName;
        this.artLastname = artLastname;
        this.artPicture = artPicture;
        this.artBirthdate = artBirthdate;
        this.artBirthplace = artBirthplace;
    }

    public Integer getIdArtist() {
        return idArtist;
    }

    public void setIdArtist(Integer idArtist) {
        this.idArtist = idArtist;
    }

    public String getArtName() {
        return artName;
    }

    public void setArtName(String artName) {
        this.artName = artName;
    }

    public String getArtLastname() {
        return artLastname;
    }

    public void setArtLastname(String artLastname) {
        this.artLastname = artLastname;
    }

    public String getArtPicture() {
        return artPicture;
    }

    public void setArtPicture(String artPicture) {
        this.artPicture = artPicture;
    }

    public Date getArtBirthdate() {
        return artBirthdate;
    }

    public void setArtBirthdate(Date artBirthdate) {
        this.artBirthdate = artBirthdate;
    }

    public String getArtBirthplace() {
        return artBirthplace;
    }

    public void setArtBirthplace(String artBirthplace) {
        this.artBirthplace = artBirthplace;
    }

    @XmlTransient
    public Collection<Song> getSongCollection() {
        return songCollection;
    }

    public void setSongCollection(Collection<Song> songCollection) {
        this.songCollection = songCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idArtist != null ? idArtist.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Artist)) {
            return false;
        }
        Artist other = (Artist) object;
        if ((this.idArtist == null && other.idArtist != null) || (this.idArtist != null && !this.idArtist.equals(other.idArtist))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Artist[ idArtist=" + idArtist + " ]";
    }
    
}
